package top.zerozoo.learn.grade.service.impl;

import top.zerozoo.learn.grade.dao.AdminDao;
import top.zerozoo.learn.grade.entity.Admin;
import top.zerozoo.learn.grade.factory.DaoFactory;
import top.zerozoo.learn.grade.service.AdminService;
import top.zerozoo.learn.grade.vo.AdminInfo;

public class AdminServiceImpl implements AdminService {
    private final AdminDao adminDao = DaoFactory.get(AdminDao.class);
    @Override
    public AdminInfo login(Admin admin) {
        Admin loginAdmin = adminDao.findByUsernameAndPassword(admin.getUsername(), admin.getPassword());
        AdminInfo adminInfo = null;
        if(loginAdmin != null){
            adminInfo = AdminInfo.parse(loginAdmin);
        }
        return adminInfo;
    }
}
